#####################################################################
# Product:      KnowledgeEngine (Plone Edition)
#
# File:         __init__.py
#
# Copyright:    Copyright (c) 2004, Faulkner Technologies
#
# Author:       Brian Oliver
#
# Description:  Initialises Sub-Package Components
#####################################################################

#####################################################################
## Knowledge Engine Library Imports
# (none - done automatically. see below)

#####################################################################
## Zope Library Imports
from App.FindHomes import ppath

#####################################################################
## Python Library Imports
import os

#####################################################################
## Python Logging Configuration
import logging
log = logging.getLogger("KnowledgeEngine.Startup")
    
#####################################################################    
## Import the KnowledgeEngine Components
##
## Each KnowledgeEngine Component resides in an independant package
## (named after the component) within the Components folder
## in the KnowledgeEngine Zope Product
##
## By individually importing each component, they have a chance of
## performing their own initialisation, including appropriately
## registering themselves as part of the KnowledgeEngine product.

# The path to the KnowledgeEngine Component Packages
COMPONENTS_PATH = ppath[0] + os.sep + "KnowledgeEngine" + os.sep + "Components"

# Dynamically import each of the defined Component packages in the COMPONENTS_PATH
for component in [file for file in os.listdir(COMPONENTS_PATH) if os.path.isdir(COMPONENTS_PATH + os.sep + file)]:

    # Import the current component (if it doesn't contain a .)
    if component.find(".") < 0:
        log.info("Registering Component: " + component)

        exec "from Products.KnowledgeEngine.Components." + component + " import *"

#####################################################################    
